﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sparrow.Reflection
{
    public class PropertyProxy
    {
        public PropertyProxy(object instance)
        {
            this.Instance = instance;
        }

        object Instance
        {
            get;
            set;
        }

    

        public object this[string name]
        {
            get
            {
                var getter = Instance.Metadata().Properties[name];
                if (getter != null)
                {
                    return getter.GetValue(this.Instance);
                }
                return null;
            }
            set
            {
                var setter = Instance.Metadata().Properties[name];
                if (setter != null)
                {
                    setter.SetValue(this.Instance,value);
                }
            }
        }
    }
}
